<div class="new-product-block">
    <?php $i = 0; ?>
    <?php foreach($this->data as $row): ?>
    
    <?php if($i == count($this->data) || $i % 3 == 0): ?>
        </ul>
    <?php endif; ?>
    
    <?php if($i == 0 || $i % 3 == 0): ?>
        <ul id="p<?php $i + 1; ?>" class="product-grid">
    <?php endif; ?>
        <li>
            <div class="pro-img">
                <a href="<?php echo $this->url(array('name' => $this->ConvertStringToURL($row->name), 'id' => $row->id), 'product_detail', true); ?>" title="<?php echo $row->name; ?>">
                    <img style="max-height: 170px !important;" title="<?php echo $row->name; ?>" alt="<?php echo $row->name; ?>" src="<?php echo $this->baseUrl('/upload/') . $row->image; ?>" />
                </a>
            </div>
            <div class="pro-content">
                <p>
                    <a href="<?php echo $this->url(array('name' => $this->ConvertStringToURL($row->name), 'id' => $row->id), 'product_detail', true); ?>" title="<?php echo $row->name; ?>">
                        <?php echo $row->name; ?>
                    </a>
                </p>
            </div>
            <div class="pro-price"><?php echo number_format($row->price, 0, null, "."); ?>đ</div>
            <div class="pro-btn-block">
                <a onclick="<?php if($row->quantity >= $this->page('out_of_stock_level')): ?>addToCart('<?php echo $row->id; ?>', '<?php echo $row->price; ?>') <?php endif; ?>" class="add-cart left" href="#p<?php echo $i + 1; ?>" title="<?php echo $this->translate('add to cart'); ?>">
                    <?php if($row->quantity >= $this->page('out_of_stock_level')): ?>
                        <?php echo $this->translate('add to cart'); ?>
                    <?php else: ?>
                        <?php echo $this->translate('out of stock'); ?>
                    <?php endif; ?>
                </a>
                <a class="add-cart right quickCart inline" href="<?php echo $this->url(array('name' => $this->ConvertStringToURL($row->name), 'id' => $row->id), 'product_detail', true) ?>" title="<?php echo $this->translate('view detail'); ?>">
                    <?php echo $this->translate('view detail'); ?>
                </a>	
            </div>
            <div class="pro-link-block">
                <div class="clearfix"></div>
            </div>
        </li>
        <?php $i ++; ?>
    <?php endforeach; ?>
</div>
<div class="pager-container">
    <?php //echo $this->render('pagination.phtml'); ?>
</div>
<script>
function addToCart(id, price){
    var qty = 1;
    
    $.ajax({
        url: "<?php echo $this->url(array(), 'addCart', true); ?>",
        data: {'id': id, 'qty': qty, 'price': price},
        success: function callback(e){
            alert('<?php echo $this->translate('add to cart success') ?>');
            loadCart();
        }
    });
}
</script>